package com.example.xpvideo.Controller;

import com.example.xpvideo.entity.PageResult;
import com.example.xpvideo.entity.ResponseResult;
import com.example.xpvideo.entity.req.*;
import com.example.xpvideo.entity.res.CommodityListRes;
import com.example.xpvideo.entity.res.LocalGoodsDetailRes;
import com.example.xpvideo.entity.res.LocalGoodsRes;
import com.example.xpvideo.service.LocalGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/back/localgoods")
public class LocalGoodsController {
    @Autowired
    private LocalGoodsService localGoodsService;

    /**
     * 首页商品列表
     * */
    @GetMapping("/list")
    public ResponseResult<PageResult<List<LocalGoodsRes>>> list(PHPCommodityReq phpCommodityReq)
            throws Exception{
        return localGoodsService.list(phpCommodityReq);
    }

    /**
     * 首页商品列表
     * */
    @GetMapping("/detail")
    public ResponseResult<LocalGoodsDetailRes> list(Integer id)
            throws Exception{
        return localGoodsService.detail(id);
    }

    @PostMapping("/audit")
    public ResponseResult<Object> audit(@NotNull @RequestBody AuditReq auditReq) throws Exception{
        return localGoodsService.audit(auditReq);
    }
    @PostMapping("/shelf")
    public ResponseResult<Object> shelf(@NotNull @RequestBody
                                        UpdateReq updateReq) throws Exception{
        return localGoodsService.shelf(updateReq);
    }
    @PostMapping("/delete")
    public ResponseResult<Object> delete(@NotNull @RequestBody UpdateReq updateReq) throws Exception{
        return localGoodsService.delete(updateReq);
    }

    @PostMapping("/recommend")
    public ResponseResult<Object> recommend(@NotNull @RequestBody
                                            RecommendReq recommendReq) throws Exception{
        return localGoodsService.recommend(recommendReq);
    }

}
